import api from './axios';

/**
 * 系统设置相关的API服务
 */
const settingsService = {
  /**
   * 获取所有系统设置
   * @returns {Promise} - 返回系统设置
   */
  getSystemSettings: async () => {
    return api.get('/settings/system');
  },

  /**
   * 更新系统设置
   * @param {Object} settings - 系统设置
   * @returns {Promise} - 返回更新结果
   */
  updateSystemSettings: async (settings) => {
    return api.put('/settings/system', settings);
  },

  /**
   * 获取PUA检测设置
   * @returns {Promise} - 返回PUA检测设置
   */
  getPuaDetectionSettings: async () => {
    return api.get('/settings/pua-detection');
  },

  /**
   * 更新PUA检测设置
   * @param {Object} settings - PUA检测设置
   * @returns {Promise} - 返回更新结果
   */
  updatePuaDetectionSettings: async (settings) => {
    return api.put('/settings/pua-detection', settings);
  },

  /**
   * 获取回复模板设置
   * @returns {Promise} - 返回回复模板设置
   */
  getReplyTemplateSettings: async () => {
    return api.get('/settings/reply-templates');
  },

  /**
   * 更新回复模板设置
   * @param {Object} settings - 回复模板设置
   * @returns {Promise} - 返回更新结果
   */
  updateReplyTemplateSettings: async (settings) => {
    return api.put('/settings/reply-templates', settings);
  },

  /**
   * 重置所有设置为默认值
   * @returns {Promise} - 返回重置结果
   */
  resetAllSettings: async () => {
    return api.post('/settings/reset');
  },

  /**
   * 导出设置
   * @returns {Promise} - 返回导出的设置数据
   */
  exportSettings: async () => {
    return api.get('/settings/export', { responseType: 'blob' });
  },

  /**
   * 导入设置
   * @param {FormData} formData - 包含设置文件的表单数据
   * @returns {Promise} - 返回导入结果
   */
  importSettings: async (formData) => {
    return api.post('/settings/import', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
  }
};

export default settingsService; 